﻿<%@ page contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<head>
<title>修改看点</title>
<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
<link href="<%=request.getContextPath()%>/style/adminStyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.min.js"></script>
<script src="<%=request.getContextPath()%>/js/jquery.js"></script>

<script type="text/javascript">
function show1(f) {
    var str = "";
    for (var i = 0; i < f.length; i++) {
        var reader = new FileReader();
        reader.readAsDataURL(f[i]);
        reader.onload = function (e) {
            str += "<img  height='50' width='50' id='img' src='" + e.target.result + "'/>";
            $("#img1")[0].outerHTML = str;
        }
    }        
}
function show2(f) {
    var str = "";
    for (var i = 0; i < f.length; i++) {
        var reader = new FileReader();
        reader.readAsDataURL(f[i]);
        reader.onload = function (e) {
            str += "<img  height='50' width='50' id='img' src='" + e.target.result + "'/>";
            $("#img2")[0].outerHTML = str;
        }
    }        
}
function show3(f) {
	
    var str = "";
    for (var i = 0; i < f.length; i++) {
        var reader = new FileReader();
        reader.readAsDataURL(f[i]);
        reader.onload = function (e) {
        	
        	
            str += "<img  height='50' width='50' id='img' src='" + e.target.result + "'/>";
            $("#img3")[0].outerHTML = str;
        }
    }   
    
   
     
}
</script>
</head>
<body>
 <div class="wrap">
  <div class="page-title">
    <span class="modular fl"><i class="settings"></i><em>看点</em></span>
  </div>
  <form >
  <table class="noborder">
   <tr>
    <td style="text-align:right;"><b>ID：</b></td>
    <td>
  
     <input type="text" class="textBox length-long" value="${news.id}" id="id" readonly="readonly"/>
      
    </td>
   </tr>
   <tr>
    <td style="width:15%;text-align:right;"><b>一级分类：</b></td>
    <td>
    <select class="textBox" id="firstclass">
     	<option value="${news.firstclass}">${news.firstclass}</option>    
      </select>
    </td>
   </tr>
   
   <tr>
    <td style="text-align:right;"><b>二级分类：</b></td>
    <td>
  
     <input type="text" class="textBox length-long" value="${news.towclass}" id="towclass"/>
      
    </td>
   </tr>
   <tr>
    <td style="text-align:right;"><b>标题：</b></td>
    <td>
      <input type="text" class="textBox length-long" value="${news.title}" id="title"/>
    </td>
   </tr>
   <tr>
  
    <td style="text-align:right;"><b>上传第一块图片：</b></td>
    <td style="width: 50px; height: 50px;"><img height="50" width="50" id="img1" src="${news.url1}"/><input type="file" id="file1" class="inputfile1" onchange="show1(this.files)"  accept="image/*"/> 
	</td>
   </tr>
  
   <tr>
    <td style="text-align:right;"><b>看点第一块内容：</b></td>
    <td><textarea class="textarea"  id="content1">${news.content1}</textarea></td>
   </tr>
   
     <tr>
     
    <td style="text-align:right;"><b>上传第二块图片：</b></td>
    <td style="width: 50px; height: 50px;"><img height="50" width="50" id="img2"  src="${news.url2}"/><input type="file"  id="file2" class="inputfile2" onchange="show2(this.files)"  accept="image/*"/> 
	</td>
   </tr>
 
   
   <tr>
    <td style="text-align:right;"><b>看点第二块内容：</b></td>
    <td><textarea class="textarea"  id="content2">${news.content2}</textarea></td>
   </tr>
   
     <tr>
    
    <td style="text-align:right;"><b>上传第三块图片：</b></td>
     <td style="width: 50px; height: 50px;"><img height="50" width="50" id="img3"  src="${news.url3}"/><input type="file"  id="file3" class="inputfile3" onchange="show3(this.files)"  accept="image/*"/> 
	</td>
    
   </tr>
   <tr>
    <td style="text-align:right;"><b>看点第三块内容：</b></td>
    <td><textarea class="textarea"  id="content3">${news.content3}</textarea></td>
   </tr>
   <tr>
    <td style="text-align:right;"></td>
    <td><input type="button" value="修改" class="tdBtn" onclick="return outlet2()"/><span style="color:red">&nbsp;*若需修改,请重新上传图片</span></td>
   </tr>
  </table>
  </form>
 </div>
 <script type="text/javascript">
 
	
 
 function outlet2(){
		var msg = "您确定要修改吗？\n\n请确认！";
		
		var ids=$("#id").val();
		var towclasss=$("#towclass").val();//二级分类
		var titles=$("#title").val();
		
		 var file1s = $("#file1")[0].files[0];
		var content1s=$("#content1").val();
		
		var file2s = $("#file2")[0].files[0];
		var content2s=$("#content2").val();
		
		var file3s= $("#file3")[0].files[0];
		var content3s=$("#content3").val();
	
		 
		var formData = new FormData();
		formData.append("ids",ids);
		formData.append("titles",titles);
	  	formData.append("towclasss",towclasss);
		formData.append("files",file1s);
		formData.append("files",file2s);
		formData.append("files",file3s);
		formData.append("content1s",content1s);
		formData.append("content2s",content2s);
		formData.append("content3s",content3s);
		if (confirm(msg)==true){
			
			$.ajax({
				"url":"${pageContext.request.contextPath}/Administrators/addtising_up.do",
				"data":formData,
				"type":"POST",
				"dataType":"json",
				"cache": false,
				"processData": false,
				"contentType": false,
				async: false,
				"success":function(o){
					if(o.state==1){
						 alert("修改成功");
						window.location="${pageContext.request.contextPath}/Administrators/advertising_list.do";
					}else{
						 alert("修改失败");
					}
					
			
				}});
			
		
		}
		}
 
 
 </script>
</body>
</html>